Assignemnt #50 and Forty-seventh Program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: forty-seventh Program
///File name: Fourt7Prog.java
///Date Finished:10/23/2015
import java.util.Scanner;
public class Fort7Prog
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Comparing \"cake\" with \"cookie\" produces ");
int i = "cake".compareTo("cookie");
System.out.println(i);
System.out.print("Comparing \"Hamburger\" with \"CheeseBurger\" produces ");
System.out.println( "Hamburger".compareTo("CheeseBurger") );
System.out.print("Comparing \"man\" with \"woman\" produces ");
System.out.println( "man".compareTo("woman") );
System.out.print("Comparing \"carol\" with \"sport\" produces ");
System.out.println( "carol".compareTo("sport") );
System.out.print("Comparing \"gun\" with \"sled\" produces ");
System.out.println( "gun".compareTo("sled") );
System.out.print("Comparing \"fans\" with \"game\" produces ");
System.out.println( "fans".compareTo("game") );
System.out.print("Comparing \"imp\" with \"computer\" produces ");
System.out.println( "imp".compareTo("computer") );
System.out.print("Comparing \"slug\" with \"banana\" produces ");
System.out.println( "slug".compareTo("banana") );
System.out.print("Comparing \"jumpsuit\" with \"cat\" produces ");
System.out.println( "jumpsuit".compareTo("cat") );
System.out.print("Comparing \"tank\" with \"salt\" produces ");
System.out.println( "tank".compareTo("salt") );
System.out.print("Comparing \"hair\" with \"hair\" produces ");
System.out.println( "hair".compareTo("hair") );
System.out.print("Comparing \"van\" with \"van\" produces ");
System.out.println( "van".compareTo("van") );
}
}
Picture of the output